package o;

import com.huawei.secure.android.common.ssl.SecureSSLSocketFactory;
import com.huawei.secure.android.common.ssl.SecureX509TrustManager;
import java.io.IOException;
import java.net.Proxy;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import o.fuv.b;

public class dnb {
    private static fuv ˊ = null;
    private static boolean ˋ = false;
    private static final byte[] ˏ = new byte[0];
    private static fuv ॱ = null;

    static class c implements HostnameVerifier {
        private c() {
        }

        public boolean verify(String str, SSLSession sSLSession) {
            return true;
        }
    }

    static class e implements X509TrustManager {
        private e() {
        }

        public void checkClientTrusted(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
        }

        public void checkServerTrusted(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
        }

        public X509Certificate[] getAcceptedIssuers() {
            return new X509Certificate[0];
        }
    }

    public static boolean ˋ() {
        return ˋ;
    }

    public static void ˎ(boolean z) {
        ˋ = z;
    }

    public static b ˊ(dmw o_dmw) {
        ful o_fun = new fun();
        o_fun.ˋ(o_dmw.ˋ());
        o_fun.ॱ(o_dmw.ˏ());
        o_fun.ˊ(o_dmw.ˊ());
        b bVar = new b();
        bVar.ˎ(o_fun);
        bVar.ॱ(true);
        bVar.ˎ(true);
        bVar.ˊ(new fuf(o_dmw.ˎ(), (long) o_dmw.ʻ(), TimeUnit.MINUTES));
        bVar.ˎ((long) o_dmw.ʼ(), TimeUnit.SECONDS);
        bVar.ˊ((long) o_dmw.ᐝ(), TimeUnit.SECONDS);
        bVar.ˋ((long) o_dmw.ॱॱ(), TimeUnit.SECONDS);
        if (o_dmw.ॱ()) {
            bVar.ˊ(ˎ());
        } else {
            bVar.ˊ(SecureSSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
        }
        bVar.ॱ(ˏ(o_dmw.ॱ()), ˊ(o_dmw.ॱ()));
        Proxy ˋ = doo.ˋ(ContentManager.getInstant().getContext());
        if (ˋ != null) {
            bVar.ॱ(ˋ);
        }
        return bVar;
    }

    public static fuv ॱ() {
        fuv o_fuv;
        synchronized (ˏ) {
            if (ˊ == null) {
                dmw o_dmw = new dmw();
                o_dmw.ˏ(8);
                o_dmw.ॱ(10);
                if (ʼ()) {
                    o_dmw.ʻ(6);
                    o_dmw.ʼ(6);
                    o_dmw.ᐝ(6);
                } else {
                    o_dmw.ʻ(10);
                    o_dmw.ʼ(10);
                    o_dmw.ᐝ(10);
                }
                o_dmw.ʽ();
                b ˊ = ˊ(o_dmw);
                ˊ.ॱ(200, TimeUnit.MILLISECONDS);
                ˊ = ˊ.ˋ();
            }
            o_fuv = ˊ;
        }
        return o_fuv;
    }

    public static fuv ˊ() {
        if (ॱ == null) {
            dmw o_dmw = new dmw();
            o_dmw.ˋ(2);
            o_dmw.ˎ(2);
            o_dmw.ˊ(2);
            o_dmw.ˏ(2);
            o_dmw.ʻ(15);
            o_dmw.ʼ(15);
            o_dmw.ᐝ(15);
            o_dmw.ʽ();
            ॱ = ˊ(o_dmw).ˋ();
        }
        return ॱ;
    }

    public static X509TrustManager ˊ(boolean z) {
        if (z) {
            return ʽ();
        }
        return ˏ();
    }

    private static X509TrustManager ˏ() {
        try {
            return new SecureX509TrustManager(ContentManager.getInstant().getContext());
        } catch (IOException e) {
            throw new AssertionError(e);
        } catch (NoSuchAlgorithmException e2) {
            throw new AssertionError(e2);
        } catch (CertificateException e3) {
            throw new AssertionError(e3);
        } catch (KeyStoreException e4) {
            throw new AssertionError(e4);
        }
    }

    public static SSLSocketFactory ˏ(boolean z) {
        if (z) {
            return ʻ();
        }
        return ॱॱ();
    }

    private static SSLSocketFactory ॱॱ() {
        try {
            return SecureSSLSocketFactory.getInstance(ContentManager.getInstant().getContext());
        } catch (IOException e) {
            throw new AssertionError(e);
        } catch (CertificateException e2) {
            throw new AssertionError(e2);
        } catch (NoSuchAlgorithmException e3) {
            throw new AssertionError(e3);
        } catch (IllegalAccessException e4) {
            throw new AssertionError(e4);
        } catch (KeyStoreException e5) {
            throw new AssertionError(e5);
        } catch (KeyManagementException e6) {
            throw new AssertionError(e6);
        }
    }

    private static SSLSocketFactory ʻ() {
        try {
            SSLContext instance = SSLContext.getInstance("TLS");
            instance.init(null, new TrustManager[]{ʽ()}, null);
            return instance.getSocketFactory();
        } catch (NoSuchAlgorithmException e) {
            throw new AssertionError(e);
        } catch (KeyManagementException e2) {
            throw new AssertionError(e2);
        }
    }

    public static c ˎ() {
        return new c();
    }

    private static e ʽ() {
        return new e();
    }

    private static boolean ʼ() {
        String ˋ = dod.ˋ("ro.product.locale");
        if (!dof.ˋ(ˋ) && ˋ.contains("CN")) {
            return true;
        }
        ˋ = dod.ˋ("ro.product.locale.region");
        if (dof.ˋ(ˋ) || !ˋ.contains("CN")) {
            return false;
        }
        return true;
    }
}
